
<%
Function tab3 ()
%>
    <script src="includes/constant.js"></script>
<% 
On Error Resume Next
'----------------------------------------------------------------------
Dim bol_objConn
	bol_objConn = False		

Dim AP'>>>  Seitenindex der masterseite (all)
AP = Request("ap")
If AP = "" Then
	AP = 1 
end if

'-------------------------------------------------------------------------
Dim sql_tmp_status
Dim str_fld_status

If Session("ses_i_language") = 1 Then'German
	sql_tmp_status = "SELECT i_k_status, str_status_de FROM tbl_0702_status Order by str_status_de"
	str_fld_status = "str_status_de"
end if

If Session("ses_i_language") = 2 Then'Eng
	sql_tmp_status = "SELECT i_k_status, str_status FROM tbl_0702_status Order by str_status"
	str_fld_status = "str_status"
end if

'---------------------------------------------------------------------------------------------------------------------------------------
Dim str_please_select
str_please_select = fc_value_string(Session("ses_i_language"), "var_glob_txt_1029") 'Con_Msg_06'"Please select..."

'---------------------------------------------------------------------------------------------------------------------------------------
Dim queryStr
Dim rst

Dim rst_tmp
Dim lst_wert
Dim lst_string
Dim sql_tmp
Dim sql_trainer

Dim lng_k_athlete'tbl_0401_athlete
lng_k_athlete = fc_lng_foreign_key(iu, 4)

Dim lng_fk_organization
lng_fk_organization = Session("ses_i_org")'division
'Response.Write("lng_fk_organization: " & lng_fk_organization & "<br>")

'?berpr?ft ob es eine dummy ist
Dim i_dummy_sub_org
Dim lng_fk_trainer'der trainer der eingeladen hat
i_dummy_sub_org = Session("ses_i_dummy_sub_org")
'i_dummy_sub_org = 1
'Response.Write("i_dummy_sub_org: " & i_dummy_sub_org & "<br>")

If i_dummy_sub_org = 1 Then'Typ C >>> also es gibt nur einen trainer

			queryStr = "SELECT lng_fk_trainer FROM tbl_0401_athlete WHERE lng_k_athlete = '" & lng_k_athlete & "'"
'			Response.Write(queryStr & "<br>")
'			Response.End()
			Set rst_tmp = Server.CreateObject("ADODB.RecordSet")
			rst_tmp.Open queryStr, objConn, adOpenStatic, adLockReadOnly  
			If Not rst_tmp.EOF Then
				lng_fk_trainer = rst_tmp.Fields("lng_fk_trainer").Value
			end if
			rst_tmp.Close 
			set rst_tmp = Nothing
			
	'sql_trainer = "SELECT lng_k_trainer, str_trainer, str_first_name_ac, str_last_name_ac FROM tbl_0301_trainer WHERE lng_k_trainer = '" & lng_fk_trainer & "'"	
	
	'nur bereits aktivierte trainer
	sql_trainer = "	SELECT tbl_0301_trainer.lng_k_trainer, tbl_0301_trainer.str_trainer, tbl_0301_trainer.str_first_name_ac, tbl_0301_trainer.str_last_name_ac, tbl_0101_master_id.i_link_activate " & _
	"FROM tbl_0301_trainer Inner Join tbl_0101_master_id ON tbl_0301_trainer.lng_k_trainer = tbl_0101_master_id.lng_fk_trainer " & _
	"WHERE tbl_0301_trainer.lng_k_trainer= '" & lng_fk_trainer & "' " & _
	"AND tbl_0101_master_id.i_type =  '4' " & _
	"AND tbl_0101_master_id.i_link_activate =  '1' " & _
	"Order by str_trainer"
else
	'sql_trainer = "SELECT lng_k_trainer, str_trainer, str_first_name_ac, str_last_name_ac FROM tbl_0301_trainer WHERE lng_fk_organization = '" & lng_fk_organization & "' Order by str_trainer"
	'nur bereits aktivierte trainer
	sql_trainer = "	SELECT tbl_0301_trainer.lng_k_trainer, tbl_0301_trainer.str_trainer, tbl_0301_trainer.str_first_name_ac, tbl_0301_trainer.str_last_name_ac, tbl_0101_master_id.i_link_activate " & _
	"FROM tbl_0301_trainer Inner Join tbl_0101_master_id ON tbl_0301_trainer.lng_k_trainer = tbl_0101_master_id.lng_fk_trainer " & _
	"WHERE tbl_0301_trainer.lng_fk_organization= '" & lng_fk_organization & "' " & _
	"AND tbl_0101_master_id.i_type =  '4' " & _
	"AND tbl_0101_master_id.i_link_activate =  '1' " & _
	"Order by str_trainer"

end if
'Response.Write("lng_fk_trainer: " & lng_fk_trainer & "<br>")
'Response.Write("sql_trainer: " & sql_trainer & "<br>")
'Response.End()


'primary coach
Dim lng_fk_authorizations_01
Dim i_fk_status_entry_01
    i_fk_status_entry_01 = 2
Dim i_fk_status_view_01
    i_fk_status_view_01 = 2
Dim dt_accepted_01

Dim lng_fk_authorizations_02
Dim i_fk_status_entry_02
    i_fk_status_entry_02 = 2
Dim i_fk_status_view_02
    i_fk_status_view_02 = 2
Dim dt_accepted_02

Dim lng_fk_authorizations_03
Dim i_fk_status_entry_03
    i_fk_status_entry_03 = 2
Dim i_fk_status_view_03
    i_fk_status_view_03 = 2
Dim dt_accepted_03

Dim lng_fk_authorizations_04
Dim i_fk_status_entry_04
    i_fk_status_entry_04 = 2
Dim i_fk_status_view_04
    i_fk_status_view_04 = 2
Dim dt_accepted_04

Dim i
Dim i_authorizations_sort

Dim i_delete'wichtig falls gel?scht wurde muss die seite neu geladen werden
i_delete = 0

Dim dt_now
dt_now = fc_str_date_server_format(Now(), 4)

'?berpr?ft welches datumsformat eingestellt ist -------------------------------------------------
Dim i_fk_date_format
Dim i_day
Dim i_year
Dim i_month

sql_tmp = "SELECT i_fk_date_format, dt_birthday FROM tbl_0501_user WHERE lng_k_User_ID = '" & iu & "'"
'Response.Write(SQL)
'Response.End()

Set rst_tmp = Server.CreateObject("ADODB.Recordset")
rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly   
    If Not rst_tmp.EOF Then
        i_fk_date_format = rst_tmp.Fields("i_fk_date_format").Value
    End if
	rst_tmp.Close
set rst_tmp = Nothing
If IsNull(i_fk_date_format) or Isempty(i_fk_date_format) Then
	i_fk_date_format = 1'default
end if


	
'----------------------------------------------------------------------------------------------------------------------------------------
'f?r die anzeige ------------------------------------------------------------------------------------------------------------------------	
'alle datens?tze werden jetzt abgearbeitet ----------------------------------------------------------------------------------------------
'----------------------------------------------------------------------------------------------------------------------------------------

	'#1 primary
	queryStr = "SELECT * FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = " &  lng_k_athlete & " AND i_authorizations_sort = 1"
	'Response.Write(queryStr & "<br>")
	Set rst = Server.CreateObject("ADODB.RecordSet")
	rst.Open queryStr, objConn, adOpenStatic, adLockOptimistic
	
	If Not rst.BOF or Not rst.EOF Then 
		lng_fk_authorizations_01 = rst.Fields("lng_fk_authorizations").Value
		i_fk_status_entry_01 = rst.Fields("i_entry").Value
		i_fk_status_view_01 = rst.Fields("i_view").Value
		dt_accepted_01 = rst.Fields("dt_accepted").Value
	end if 
	
    rst.Close 
	set rst = Nothing

	'ausgabeformat nur f?r den User - kommt darauf an was im dropdown ausw?hlt
	'1	dd.mm.yyyy
	'2	mm.dd.yyyy		
			If i_fk_date_format = 1 and IsDate(dt_accepted_01) Then
				dt_accepted_01 = fc_str_date_server_format(dt_accepted_01, 5)
			end if
			If i_fk_date_format = 2 and IsDate(dt_accepted_01) Then
				dt_accepted_01 = fc_str_date_server_format(dt_accepted_01, 6)
			end if
	
	'#2 ---------------------------------------------------------------------------------------------------------------------------------
	queryStr = "SELECT * FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = " &  lng_k_athlete & " AND i_authorizations_sort = 2"
	Set rst = Server.CreateObject("ADODB.RecordSet")
	rst.Open queryStr, objConn, adOpenStatic, adLockOptimistic
	'Response.Write(queryStr & "<br>")
	If Not rst.BOF or Not rst.EOF Then 
		lng_fk_authorizations_02 = rst.Fields("lng_fk_authorizations").Value
        i_fk_status_entry_02 = rst.Fields("i_entry").Value
		i_fk_status_view_02 = rst.Fields("i_view").Value
		dt_accepted_02 = rst.Fields("dt_accepted").Value
	end if 
	
    rst.Close 
	set rst = Nothing

	'ausgabeformat nur f?r den User - kommt darauf an was im dropdown ausw?hlt
	'1	dd.mm.yyyy
	'2	mm.dd.yyyy		
			If i_fk_date_format = 1 and IsDate(dt_accepted_02) Then
				dt_accepted_02 = fc_str_date_server_format(dt_accepted_02, 5)
			end if
			If i_fk_date_format = 2 and IsDate(dt_accepted_02) Then
				dt_accepted_02 = fc_str_date_server_format(dt_accepted_02, 6)
			end if

	'#3 ---------------------------------------------------------------------------------------------------------------------------------
	queryStr = "SELECT * FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = " &  lng_k_athlete & " AND i_authorizations_sort = 3"
	Set rst = Server.CreateObject("ADODB.RecordSet")
	rst.Open queryStr, objConn, adOpenStatic, adLockOptimistic
	
	If Not rst.BOF or Not rst.EOF Then 
		lng_fk_authorizations_03 = rst.Fields("lng_fk_authorizations").Value
        i_fk_status_entry_03 = rst.Fields("i_entry").Value
		i_fk_status_view_03 = rst.Fields("i_view").Value
		dt_accepted_03 = rst.Fields("dt_accepted").Value
	end if 
	
    rst.Close 
	set rst = Nothing

	'ausgabeformat nur f?r den User - kommt darauf an was im dropdown ausw?hlt
	'1	dd.mm.yyyy
	'2	mm.dd.yyyy		
			If i_fk_date_format = 1 and IsDate(dt_accepted_01) Then
				dt_accepted_03 = fc_str_date_server_format(dt_accepted_03, 5)
			end if
			If i_fk_date_format = 2 and IsDate(dt_accepted_01) Then
				dt_accepted_03 = fc_str_date_server_format(dt_accepted_03, 6)
			end if

	'#4 ---------------------------------------------------------------------------------------------------------------------------------
	queryStr = "SELECT * FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = " &  lng_k_athlete & " AND i_authorizations_sort = 4"
	Set rst = Server.CreateObject("ADODB.RecordSet")
	rst.Open queryStr, objConn, adOpenStatic, adLockOptimistic
	
	If Not rst.BOF or Not rst.EOF Then 
		lng_fk_authorizations_04 = rst.Fields("lng_fk_authorizations").Value
        i_fk_status_entry_04 = rst.Fields("i_entry").Value
		i_fk_status_view_04 = rst.Fields("i_view").Value
		dt_accepted_04 = rst.Fields("dt_accepted").Value
	end if 
	
    rst.Close 
	set rst = Nothing

	'ausgabeformat nur f?r den User - kommt darauf an was im dropdown ausw?hlt
	'1	dd.mm.yyyy
	'2	mm.dd.yyyy		
	If i_fk_date_format = 1 and IsDate(dt_accepted_04) Then
		dt_accepted_04 = fc_str_date_server_format(dt_accepted_04, 5)
	end if
	If i_fk_date_format = 2 and IsDate(dt_accepted_04) Then
		dt_accepted_04 = fc_str_date_server_format(dt_accepted_04, 6)
	end if
	
	
	
	If Err.Number Then
		Response.Write("//Errors: " & Err.Description)
		Err.Clear
	End If
	%>

<form method="post" action="athlete_measured_data.asp?active_tab=a3&action=save&AP=<%=AP%>" onsubmit="return Form_inputcheck(this)" name="frm_value_3">
<table width="650" border="0" cellspacing="4" cellpadding="0">
    <tr>
        <td valign="top">
            <table border="0" cellspacing="0" cellpadding="0" style="margin-top: 15px;">   
                <tr>
                    <td class="txtform" style="padding: 0px 10px 0px 30px; vertical-align: top;">
                        <img style="position: relative; top: -13px;" src="images/ico/authorize48.png" width="32" height="32" alt="" />
                    </td>
                    <td class="txtform" style="font-weight: bold; vertical-align: top;"><%= fc_value_string(Session("ses_i_language"), "var_remind_16") %></td>
                    <td style="vertical-align: top; width: 100px;" class="txtform">
                        <div style="padding-left: 40px; position: relative; top: -7px;">
                            <img src="images/ico/edit24.png" alt="<%= var_autho_10 %>" title="<%= var_autho_10 %>" width="24" height="24" />
                        </div>
                    </td>
                    <td style="vertical-align: top; width: 100px;" class="txtform">
                        <div style="padding-left: 40px; position: relative; top: -7px;">
                            <img src="images/ico/view24.png" alt="<%= var_autho_11 %>" title="<%= var_autho_11 %>" width="24" height="24" />
                        </div>
                    </td>
                    <td  style="vertical-align: top; width: 30px;" class="txtform">&nbsp;</td>
                </tr>
                <tr>
                    <td style="width: 40px; height: 30px;">&nbsp;</td>
                    <td width="300" valign="top" style="text-align: left;">
                        <span class="txtform">1.
                            <select style="width: 200px; margin-left: 15px;" name="LST_Authorizations_01" size="1" class="field yellow" id="LST_Authorizations_01" >
<%
'DropDown----------------------------------------------------------------------------------
sql_tmp = sql_trainer'"SELECT lng_k_trainer, str_trainer FROM tbl_0301_trainer WHERE lng_fk_organization = '" & lng_fk_organization & "' Order by str_trainer"

If Cint(lng_fk_authorizations_01) = 0 Then
		%>
		<option <%If Cint(lng_fk_authorizations_01) = 0 Then %>selected<%end if%> value="0"><%= str_please_select %></option>
		<%
end if


	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
		rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("lng_k_trainer")
		    'lst_string = rst_tmp.Fields("str_trainer")
			lst_string = rst_tmp.Fields("str_first_name_ac")
			lst_string = lst_string & " " & rst_tmp.Fields("str_last_name_ac")
			
			If len(lst_string) = 0 Then
				lst_string = rst_tmp.Fields("str_trainer")
			end if
			

%>
    <option <%If lst_wert = Cint(lng_fk_authorizations_01) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
    <%
             rst_tmp.MoveNext
			 
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
'------------------------------------------------------------------------------------------------------
If Cint(lng_fk_authorizations_01) > 0 Then
		%>
		<option value="-1"><%= str_please_select %></option>
		<%
end if
%>
</select>

</span></td>
<td valign="top" class="">
<div align="center">
<select name="LST_Status_entry_01" size="1" class="field yellow" id="LST_Status_entry_01" onclick="return LST_Status_entry_01_onclick()">
<%
'DropDown <Status>----------------------------------------------------------------------------------
 
	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
	rst_tmp.Open sql_tmp_status, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("i_k_status")
		    lst_string = rst_tmp.Fields(str_fld_status)

%>
      <option <%If lst_wert = Cint(i_fk_status_entry_01) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
<%
             rst_tmp.MoveNext
			 
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
%>
    </select>
  </div></td>
<td valign="top" class="">
  <div align="center">
    <select name="LST_Status_view_01" size="1" class="field yellow" id="LST_Status_view_01" >
<%
'DropDown <Status>----------------------------------------------------------------------------------


	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
		rst_tmp.Open sql_tmp_status, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("i_k_status")
		    lst_string = rst_tmp.Fields(str_fld_status)

%>
      <option <%If lst_wert = Cint(i_fk_status_view_01) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
      <%
             rst_tmp.MoveNext
			 
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
%>
    </select>
  </div></td>
<td valign="middle" class=""><div align="center"><%= dt_accepted_01 %></div></td>
</tr>
<tr>
  <td style="height: 30px;">&nbsp;</td>
  <td valign="top" style="text-align: left;"><span class="txtform">
    2.
    <select style="width: 200px; margin-left: 15px;" name="LST_Authorizations_02" size="1" class="field yellow" id="LST_Authorizations_02" >
      <%
'DropDown----------------------------------------------------------------------------------
sql_tmp = sql_trainer'"SELECT lng_k_trainer, str_trainer FROM tbl_0301_trainer WHERE lng_fk_organization = '" & lng_fk_organization & "' Order by str_trainer"

If Cint(lng_fk_authorizations_02) = 0 Then
		%>
		<option <%If Cint(lng_fk_authorizations_02) = 0 Then %>selected<%end if%> value="0"><%= str_please_select %></option>
		<%
end if


	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
		rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("lng_k_trainer")
		    'lst_string = rst_tmp.Fields("str_trainer")
			lst_string = rst_tmp.Fields("str_first_name_ac")
			lst_string = lst_string & " " & rst_tmp.Fields("str_last_name_ac")

%>
      <option <%If lst_wert = Cint(lng_fk_authorizations_02) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
      <%
             rst_tmp.MoveNext
			 
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
'------------------------------------------------------------------------------------------------------
If Cint(lng_fk_authorizations_02) > 0 Then
		%>
		<option value="-1"><%= str_please_select %></option>
		<%
end if
%>
    </select>

  </span></td>
  <td valign="top" class="">
      <div align="center">
        <select name="LST_Status_entry_02" size="1" class="field yellow" id="LST_Status_entry_02" >
        <%
        'DropDown <Status>----------------------------------------------------------------------------------

            Set rst_tmp = Server.CreateObject("ADODB.Recordset")
            rst_tmp.Open sql_tmp_status, objConn, adOpenStatic, adLockReadOnly   

            If Not rst_tmp.EOF Then
                 Do While Not rst_tmp.EOF

                    lst_wert = rst_tmp.Fields("i_k_status")
                    lst_string = rst_tmp.Fields(str_fld_status)

        %>
              <option <%If lst_wert = Cint(i_fk_status_entry_02) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
        <%
                     rst_tmp.MoveNext

                Loop
                End if

                rst_tmp.Close
        set rst_tmp = Nothing
        %>
        </select>
      </div>
  </td>
  <td valign="top" class=""><div align="center">

<select name="LST_Status_view_02" size="1" class="field yellow" id="LST_Status_view_02" >
<%
'DropDown <Status>----------------------------------------------------------------------------------

	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
	rst_tmp.Open sql_tmp_status, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("i_k_status")
	    	lst_string = rst_tmp.Fields(str_fld_status)

%>
      <option <%If lst_wert = Cint(i_fk_status_view_02) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
      <%
             rst_tmp.MoveNext
			 
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
%>
 </select>
  </div></td>
  <td valign="top" class=""><div align="center"><%= dt_accepted_02 %></div></td>
</tr>
<tr>
  <td style="height: 30px;">&nbsp;</td>
  <td valign="top" style="text-align: left;"><span class="txtform">
    3.
    <select style="width: 200px; margin-left: 15px;" name="LST_Authorizations_03" size="1" class="field yellow" id="LST_Authorizations_03" >
      <%
'DropDown----------------------------------------------------------------------------------
sql_tmp = sql_trainer'"SELECT lng_k_trainer, str_trainer FROM tbl_0301_trainer WHERE lng_fk_organization = '" & lng_fk_organization & "' Order by str_trainer"

If Cint(lng_fk_authorizations_03) = 0 Then
		%>
		<option <%If Cint(lng_fk_authorizations_03) = 0 Then %>selected<%end if%> value="0"><%= str_please_select %></option>
		<%
end if


	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
		rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("lng_k_trainer")
		    'lst_string = rst_tmp.Fields("str_trainer")
			lst_string = rst_tmp.Fields("str_first_name_ac")
			lst_string = lst_string & " " & rst_tmp.Fields("str_last_name_ac")

%>
      <option <%If lst_wert = Cint(lng_fk_authorizations_03) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
      <%
             rst_tmp.MoveNext
			 
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
'------------------------------------------------------------------------------------------------------
If Cint(lng_fk_authorizations_03) > 0 Then
		%>
		<option value="-1"><%= str_please_select %></option>
		<%
end if
%>
    </select>
  </span></td>
  <td valign="top" class="">
      <div align="center">
        <select name="LST_Status_entry_03" size="1" class="field yellow" id="LST_Status_entry_03" >
        <%
        'DropDown <Status>----------------------------------------------------------------------------------

            Set rst_tmp = Server.CreateObject("ADODB.Recordset")
            rst_tmp.Open sql_tmp_status, objConn, adOpenStatic, adLockReadOnly   

            If Not rst_tmp.EOF Then
                 Do While Not rst_tmp.EOF

                    lst_wert = rst_tmp.Fields("i_k_status")
                    lst_string = rst_tmp.Fields(str_fld_status)

        %>
              <option <%If lst_wert = Cint(i_fk_status_entry_03) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
        <%
                     rst_tmp.MoveNext

                Loop
                End if

                rst_tmp.Close
        set rst_tmp = Nothing
        %>
        </select>
    </div>
  </td>
  <td valign="top" class=""><div align="center">
    <select name="LST_Status_view_03" size="1" class="field yellow" id="LST_Status_view_03" >
      <%
'DropDown <Status>----------------------------------------------------------------------------------

	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
		rst_tmp.Open sql_tmp_status, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("i_k_status")
		    lst_string = rst_tmp.Fields(str_fld_status)

%>
      <option <%If lst_wert = Cint(i_fk_status_view_03) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
      <%
             rst_tmp.MoveNext
			 
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
%>
    </select>
  </div></td>
  <td valign="top" class=""><div align="center"><%= dt_accepted_03 %></div></td>
</tr>
<tr>
  <td valign="top" class="">&nbsp;</td>
  <td valign="top" style="text-align: left;"><span class="txtform">
    4.
    <select style="width: 200px; margin-left: 15px;" name="LST_Authorizations_04" size="1" class="field yellow" id="LST_Authorizations_04" >
      <%
'DropDown----------------------------------------------------------------------------------
sql_tmp = sql_trainer'"SELECT lng_k_trainer, str_trainer FROM tbl_0301_trainer WHERE lng_fk_organization = '" & lng_fk_organization & "' Order by str_trainer"

If Cint(lng_fk_authorizations_04) = 0 Then
		%>
		<option <%If Cint(lng_fk_authorizations_04) = 0 Then %>selected<%end if%> value="0"><%= str_please_select %></option>
		<%
end if


	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
		rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("lng_k_trainer")
		    'lst_string = rst_tmp.Fields("str_trainer")
			lst_string = rst_tmp.Fields("str_first_name_ac")
			lst_string = lst_string & " " & rst_tmp.Fields("str_last_name_ac")

%>
      <option <%If lst_wert = Cint(lng_fk_authorizations_04) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
      <%
             rst_tmp.MoveNext
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
'------------------------------------------------------------------------------------------------------
If Cint(lng_fk_authorizations_04) > 0 Then
		%>
		<option value="-1"><%= str_please_select %></option>
		<%
end if
%>
    </select>
  </span></td>
  <td valign="top" class="">
      <div align="center">
        <select name="LST_Status_entry_04" size="1" class="field yellow" id="LST_Status_entry_04" >
        <%
        'DropDown <Status>----------------------------------------------------------------------------------

            Set rst_tmp = Server.CreateObject("ADODB.Recordset")
            rst_tmp.Open sql_tmp_status, objConn, adOpenStatic, adLockReadOnly   

            If Not rst_tmp.EOF Then
                 Do While Not rst_tmp.EOF

                    lst_wert = rst_tmp.Fields("i_k_status")
                    lst_string = rst_tmp.Fields(str_fld_status)

        %>
              <option <%If lst_wert = Cint(i_fk_status_entry_04) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
        <%
                     rst_tmp.MoveNext

                Loop
                End if

                rst_tmp.Close
        set rst_tmp = Nothing
        %>
        </select>
    </div>
  </td>
  <td valign="top" class=""><div align="center">
    <select name="LST_Status_view_04" size="1" class="field yellow" id="LST_Status_view_04" >
      <%
'DropDown <Status>----------------------------------------------------------------------------------

	Set rst_tmp = Server.CreateObject("ADODB.Recordset")
		rst_tmp.Open sql_tmp_status, objConn, adOpenStatic, adLockReadOnly   

    If Not rst_tmp.EOF Then
	     Do While Not rst_tmp.EOF
          
            lst_wert = rst_tmp.Fields("i_k_status")
		    lst_string = rst_tmp.Fields(str_fld_status)

%>
      <option <%If lst_wert = Cint(i_fk_status_view_04) Then %>selected<%end if%> value="<%=lst_wert%>"><%=lst_string%></option>
      <%
             rst_tmp.MoveNext
			 
        Loop
  		End if

		rst_tmp.Close
set rst_tmp = Nothing
%>
    </select>
  </div>
  </td>
  <td valign="top" class=""><div align="center"><%= dt_accepted_04 %></div></td>
</tr>
<tr>
<td valign="bottom">&nbsp;</td>
<td valign="bottom">&nbsp;</td>
<td valign="bottom">&nbsp;</td>
<td valign="bottom">&nbsp;</td>
<td valign="bottom">&nbsp;</td>
</tr>
<tr>
    <td colspan="2">&nbsp;</td>
    <td colspan="2" style="text-align: right; padding-top: 10px; padding-right: 15px;">
        <input name="btnSub_tab3" type="submit" class="button130" style="width: 110px;" title="<%= var_autho_09 %>" value="<%= fc_value_string(Session("ses_i_language"), "var_autho_07") %>" />
    </td>
    <td>&nbsp;</td>
</tr>
<tr>
    <td colspan="5" style="height: 15mm;">
        <a name='reminder'></a>
    </td>
</tr>
<tr>
    <td class="txtform" style="padding: 0px 10px 0px 30px; vertical-align: top;">
        <img style="position: relative; top: -13px;" src="images/ico/calendar32.png" width="32" height="32" alt="" />
    </td>
    <td colspan="4" class="txtform" style="font-weight: bold; vertical-align: top;"><%= fc_value_string(Session("ses_i_language"), "var_remind_17") %></td>
</tr>
<tr>
    <td>&nbsp;</td>
    <td colspan="3" style="font-variant: small-caps;" class="reminder_td">
        <p class="cap_p" style="margin: 0px 20px 0px 0px;">
            <%= fc_value_string(Session("ses_i_language"), "var_remind_01") %>
        </p>
        <p class="cap_p" style="margin-top: 7mm;">
            <%= fc_value_string(Session("ses_i_language"), "var_remind_02") %>
        </p>
        <select name="timezone" id="timezone" class="field yellow" style="width: 460px;">
            <% call getTimeZonesCode() %>
        </select>
        <img style="position: relative; left: 16px;" src="images/ico/help16.png" alt="" width="16" height="16" hspace="10" class="help" onmouseover="Tip('<%= fc_value_string(Session("ses_i_language"), "var_hints_68") %>', TITLE, '&lt;div class=\'TitleCls\'&gt;<%= fc_value_string_hint_title(Session("ses_i_language"), "var_hints_01", "var_hints_68") %>&lt;/div&gt;')" onmouseout="UnTip()" />
        <p class="cap_p" style="margin-top: 7mm;">
            <%= fc_value_string(Session("ses_i_language"), "var_remind_03") %>
        </p>
        <div>
            <div style="width: 200px; float: left; padding-top: 5px;">
                <%= fc_value_string(Session("ses_i_language"), "var_remind_04") %>
                <span style="color: Red;">*</span>
            </div>
            <select name="prime_email" id="prime_email" class="field yellow" style="width: 260px;" onchange="email_onchange(this);">
                <option value="0"><%= str_please_select %></option>
                <% call getEmailsCode(lng_k_athlete, 1) %>
            </select>
            <img style="position: relative; left: 16px;" src="images/ico/help16.png" alt="" width="16" height="16" hspace="10" class="help" onmouseover="Tip('<%= fc_value_string(Session("ses_i_language"), "var_hints_69") %>', TITLE, '&lt;div class=\'TitleCls\'&gt;<%= fc_value_string_hint_title(Session("ses_i_language"), "var_hints_01", "var_hints_69") %>&lt;/div&gt;')" onmouseout="UnTip()" />
            <div id="diff_email_1_div" style="display: none;">
                <div style="width: 200px; float: left;">&nbsp;</div>
                <input type="text" value="<%= g_first_email %>" name="diff_email_1" id="diff_email_1" class="field yellow" style="width: 256px; background-color: #FAD0D4;" />
            </div>
        </div>
        <div>
            <div style="width: 200px; float: left; padding-top: 3px;">
                <%= fc_value_string(Session("ses_i_language"), "var_remind_05") %>
            </div>
            <select name="second_email" id="second_email" class="field yellow" style="width: 260px;" onchange="email_onchange(this);">
                <option value="0"><%= str_please_select %></option>
                <% call getEmailsCode(lng_k_athlete, 0) %>
            </select>
            <img style="position: relative; left: 16px;" src="images/ico/help16.png" alt="" width="16" height="16" hspace="10" class="help" onmouseover="Tip('<%= fc_value_string(Session("ses_i_language"), "var_hints_70") %>', TITLE, '&lt;div class=\'TitleCls\'&gt;<%= fc_value_string_hint_title(Session("ses_i_language"), "var_hints_01", "var_hints_70") %>&lt;/div&gt;')" onmouseout="UnTip()" />
            <div id="diff_email_2_div" style="display: none;">
                <div style="width: 200px; float: left;">&nbsp;</div>
                <input type="text" value="<%= g_second_email %>" name="diff_email_2" id="diff_email_2" class="field yellow" style="width: 256px; background-color: #FAD0D4;" />
            </div>
        </div>
        <div style="margin-top: 7mm;">
            <div style="width: 200px; float: left; padding-top: 4px;">
                <%= fc_value_string(Session("ses_i_language"), "var_remind_06") %>
                <span style="color: Red;">*</span>
            </div>
            <%
                Dim next_mease
                if g_next_mease = "" then
                    next_mease = fc_value_string(Session("ses_i_language"), "var_remind_14")
                else
                    next_mease = g_next_mease
                end if
            %>
            <input value="<%= next_mease %>" type="text" id="next_measurement" name="next_measurement" class="field yellow" readonly="readonly" style="width: 152px; cursor: pointer;" />
            <img style="position: relative; left: 16px;" src="images/ico/help16.png" alt="" width="16" height="16" hspace="10" class="help" onmouseover="Tip('<%= fc_value_string(Session("ses_i_language"), "var_hints_71") %>', TITLE, '&lt;div class=\'TitleCls\'&gt;<%= fc_value_string_hint_title(Session("ses_i_language"), "var_hints_01", "var_hints_71") %>&lt;/div&gt;')" onmouseout="UnTip()" />
        </div>
        <div>
            <div style="width: 200px; float: left; padding-top: 4px;">
                <%= fc_value_string(Session("ses_i_language"), "var_remind_07") %>
            </div>
            <select name="interval_plan" id="interval_plan" class="field yellow" style="width: 155px;">
               <% call getIntervalOrRemindMeCode(1) %>
            </select>
            <img style="position: relative; left: 16px;" src="images/ico/help16.png" alt="" width="16" height="16" hspace="10" class="help" onmouseover="Tip('<%= fc_value_string(Session("ses_i_language"), "var_hints_72") %>', TITLE, '&lt;div class=\'TitleCls\'&gt;<%= fc_value_string_hint_title(Session("ses_i_language"), "var_hints_01", "var_hints_72") %>&lt;/div&gt;')" onmouseout="UnTip()" />
        </div>
        <div>
            <div style="width: 200px; float: left; padding-top: 4px;">
                <%= fc_value_string(Session("ses_i_language"), "var_remind_08") %>
            </div>
            <select name="remind_me" id="remind_me" class="field yellow" style="width: 155px;">
                <% call getIntervalOrRemindMeCode(0) %>
            </select>
            <img style="position: relative; left: 16px;" src="images/ico/help16.png" alt="" width="16" height="16" hspace="10" class="help" onmouseover="Tip('<%= fc_value_string(Session("ses_i_language"), "var_hints_73") %>', TITLE, '&lt;div class=\'TitleCls\'&gt;<%= fc_value_string_hint_title(Session("ses_i_language"), "var_hints_01", "var_hints_73") %>&lt;/div&gt;')" onmouseout="UnTip()" />
        </div>
        <table style="margin-top: 7mm; margin-bottom: 10mm; font-variant: normal;" cellpadding="0" cellspacing="0">
            <tr>
                <td style="width: 200px; vertical-align: top;">
                    <input onclick="pauseReminder(this);" style="position: relative; top: 2px; padding-left: 0px;" type="checkbox" name="pause" id="pause" value="1" />
                    <%= fc_value_string(Session("ses_i_language"), "var_remind_09") %>
                    <img style="position: relative; left: 0px;" src="images/ico/help16.png" alt="" width="16" height="16" hspace="10" class="help" onmouseover="Tip('<%= fc_value_string(Session("ses_i_language"), "var_hints_74") %>', TITLE, '&lt;div class=\'TitleCls\'&gt;<%= fc_value_string_hint_title(Session("ses_i_language"), "var_hints_01", "var_hints_74") %>&lt;/div&gt;')" onmouseout="UnTip()" />
                </td>
                <td style="width: 150px; vertical-align: bottom;">
                    &nbsp;
                </td>
                <td style="text-align: left; width: 120px; vertical-align: top;">
                    <input type="button" onclick="saveReminder()" style="width: 110px;" class="button130" value="<%= fc_value_string(Session("ses_i_language"), "var_autho_07") %>" />
                           <div style="text-align: center; padding-top: 10px;">
                         <a style="font-size: 10px;" href="javascript: void(0)"><%= fc_value_string(Session("ses_i_language"), "var_remind_10") %></a>
                    </div>
                </td>
            </tr>
        </table>
    </td>
    <td>&nbsp;</td>
</tr>
</table>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
  </form>
<style type="text/css">
    @-moz-document url-prefix() {
        .cap_p {
            /*letter-spacing: -0.5px;*/
            word-spacing: 1;
            margin-right: 0px !important;
        }
    }
</style>
	<%
	If bol_objConn = True Then           
        objConn.Close 
	set objConn = Nothing 
	bol_objConn = False
end if
End Function

Function tab3_save()
    On Error Resume Next
    '----------------------------------------------------------------------
    Dim bol_objConn
        bol_objConn = False		

    Dim AP'>>>  Seitenindex der masterseite (all)
    AP = Request("ap")
    If AP = "" Then
        AP = 1 
    end if

    '-------------------------------------------------------------------------
    Dim sql_tmp_status
    Dim str_fld_status

    If Session("ses_i_language") = 1 Then'German
        sql_tmp_status = "SELECT i_k_status, str_status_de FROM tbl_0702_status Order by str_status_de"
        str_fld_status = "str_status_de"
    end if

    If Session("ses_i_language") = 2 Then'Eng
        sql_tmp_status = "SELECT i_k_status, str_status FROM tbl_0702_status Order by str_status"
        str_fld_status = "str_status"
    end if

    '---------------------------------------------------------------------------------------------------------------------------------------
    Dim str_please_select
    str_please_select = fc_value_string(Session("ses_i_language"), "var_glob_txt_1029") 'Con_Msg_06'"Please select..."
    Dim trancd_tab3
    Dim btnSub_tab3

    btnSub_tab3 = Request("btnSub_tab3") 
    trancd_tab3 = "A"'default

    'Save - update
    If Len(btnSub_tab3) > 0 Then
        trancd_tab3 = "S"
    end if

    Dim input_grafik
    input_grafik = Request("btnSub")
    'Response.Write("#3 input_grafik: " & input_grafik & "<br>")

    If trancd_tab3 = "A" and Len(input_grafik) > 0 Then'm?glicherweise wurde eine Grafik bet?tigt
        trancd_tab3 = UCase(Left(Request("btnSub"),1))
        'Response.Write("#2 trancd_tab3 " & trancd_tab3 & "<br>")
        'falls nicht bet?tigt wurde bleibt A
        'S > save ... bestehnder datensatz speichern
        If instr("S", trancd_tab3) = 0 Then
            trancd_tab3 = "A"
        End If
    End If

    '---------------------------------------------------------------------------------------------------------------------------------------
    Dim queryStr
    Dim rst

    Dim rst_tmp
    Dim lst_wert
    Dim lst_string
    Dim sql_tmp
    Dim sql_trainer

    Dim lng_k_athlete'tbl_0401_athlete
    lng_k_athlete = fc_lng_foreign_key(iu, 4)

    Dim lng_fk_organization
    lng_fk_organization = Session("ses_i_org")'division
    'Response.Write("lng_fk_organization: " & lng_fk_organization & "<br>")

    '?berpr?ft ob es eine dummy ist
    Dim i_dummy_sub_org
    Dim lng_fk_trainer'der trainer der eingeladen hat
    i_dummy_sub_org = Session("ses_i_dummy_sub_org")
    'i_dummy_sub_org = 1
    'Response.Write("i_dummy_sub_org: " & i_dummy_sub_org & "<br>")

    If i_dummy_sub_org = 1 Then'Typ C >>> also es gibt nur einen trainer

                queryStr = "SELECT lng_fk_trainer FROM tbl_0401_athlete WHERE lng_k_athlete = '" & lng_k_athlete & "'"
    '			Response.Write(queryStr & "<br>")
    '			Response.End()
                Set rst_tmp = Server.CreateObject("ADODB.RecordSet")
                rst_tmp.Open queryStr, objConn, adOpenStatic, adLockReadOnly  
                If Not rst_tmp.EOF Then
                    lng_fk_trainer = rst_tmp.Fields("lng_fk_trainer").Value
                end if
                rst_tmp.Close 
                set rst_tmp = Nothing

        'sql_trainer = "SELECT lng_k_trainer, str_trainer, str_first_name_ac, str_last_name_ac FROM tbl_0301_trainer WHERE lng_k_trainer = '" & lng_fk_trainer & "'"	

        'nur bereits aktivierte trainer
        sql_trainer = "	SELECT tbl_0301_trainer.lng_k_trainer, tbl_0301_trainer.str_trainer, tbl_0301_trainer.str_first_name_ac, tbl_0301_trainer.str_last_name_ac, tbl_0101_master_id.i_link_activate " & _
        "FROM tbl_0301_trainer Inner Join tbl_0101_master_id ON tbl_0301_trainer.lng_k_trainer = tbl_0101_master_id.lng_fk_trainer " & _
        "WHERE tbl_0301_trainer.lng_k_trainer= '" & lng_fk_trainer & "' " & _
        "AND tbl_0101_master_id.i_type =  '4' " & _
        "AND tbl_0101_master_id.i_link_activate =  '1' " & _
        "Order by str_trainer"
    else
        'sql_trainer = "SELECT lng_k_trainer, str_trainer, str_first_name_ac, str_last_name_ac FROM tbl_0301_trainer WHERE lng_fk_organization = '" & lng_fk_organization & "' Order by str_trainer"
        'nur bereits aktivierte trainer
        sql_trainer = "	SELECT tbl_0301_trainer.lng_k_trainer, tbl_0301_trainer.str_trainer, tbl_0301_trainer.str_first_name_ac, tbl_0301_trainer.str_last_name_ac, tbl_0101_master_id.i_link_activate " & _
        "FROM tbl_0301_trainer Inner Join tbl_0101_master_id ON tbl_0301_trainer.lng_k_trainer = tbl_0101_master_id.lng_fk_trainer " & _
        "WHERE tbl_0301_trainer.lng_fk_organization= '" & lng_fk_organization & "' " & _
        "AND tbl_0101_master_id.i_type =  '4' " & _
        "AND tbl_0101_master_id.i_link_activate =  '1' " & _
        "Order by str_trainer"

    end if
    'Response.Write("lng_fk_trainer: " & lng_fk_trainer & "<br>")
    'Response.Write("sql_trainer: " & sql_trainer & "<br>")
    'Response.End()


    'primary coach
    Dim lng_fk_authorizations_01
    Dim i_fk_status_entry_01
    Dim i_fk_status_view_01
    Dim dt_accepted_01

    Dim lng_fk_authorizations_02
    Dim i_fk_status_entry_02
    Dim i_fk_status_view_02
    Dim dt_accepted_02

    Dim lng_fk_authorizations_03
    Dim i_fk_status_entry_03
    Dim i_fk_status_view_03
    Dim dt_accepted_03

    Dim lng_fk_authorizations_04
    Dim i_fk_status_entry_04
    Dim i_fk_status_view_04
    Dim dt_accepted_04

    Dim i
    Dim i_authorizations_sort

    Dim i_delete'wichtig falls gel?scht wurde muss die seite neu geladen werden
    i_delete = 0

    Dim dt_now
    dt_now = fc_str_date_server_format(Now(), 4)

    '?berpr?ft welches datumsformat eingestellt ist -------------------------------------------------
    Dim i_fk_date_format
    Dim i_day
    Dim i_year
    Dim i_month

    sql_tmp = "SELECT i_fk_date_format, dt_birthday FROM tbl_0501_user WHERE lng_k_User_ID = '" & iu & "'"
    'Response.Write(SQL)
    'Response.End()

    Set rst_tmp = Server.CreateObject("ADODB.Recordset")
    rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly   
        If Not rst_tmp.EOF Then
            i_fk_date_format = rst_tmp.Fields("i_fk_date_format").Value
        End if
        rst_tmp.Close
    set rst_tmp = Nothing
    If IsNull(i_fk_date_format) or Isempty(i_fk_date_format) Then
        i_fk_date_format = 1'default
    end if


        Select Case trancd_tab3

            Case "S"

            '#1 -------------------------------------------------------------------------------------------------------------------------------
                i_authorizations_sort = 1'primary
                lng_fk_authorizations_01 = Request("LST_Authorizations_01")
                If IsNull(Cint(lng_fk_authorizations_01)) or IsEmpty(Cint(lng_fk_authorizations_01)) or Cint(lng_fk_authorizations_01) = 0 Then
                    lng_fk_authorizations_01 = 0
                end if
                i_fk_status_entry_01 = Request("LST_Status_entry_01")
                i_fk_status_view_01 = Request("LST_Status_view_01")

                'zuerst muss ?berpr?ft werden ob es nicht schon einen datensatz gibt
                sql_tmp = "SELECT COUNT(1) AS i FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = " &  lng_k_athlete & " AND i_authorizations_sort = " & i_authorizations_sort
                'Response.Write(sql_tmp & "<br>")

                Set rst_tmp = Server.CreateObject("ADODB.RecordSet")
                i = 0 
                rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly  
                    i = rst_tmp.Fields("i")
                    rst_tmp.close
                set rst_tmp = Nothing 
                'i_type = 4  >>> Trainer

                If Cint(i) = 0 and Cint(lng_fk_authorizations_01) > 0 Then'neuanlage
                    sql_tmp = "INSERT INTO tbl_0402_athlete_authorizations " & _
                         "(" & _
                              " lng_fk_athlete" & _
                              ", lng_fk_authorizations" & _
                              ", i_type" & _
                              ", i_entry" & _
                              ", i_view" & _
                              ", i_authorizations_sort" & _
                              ", dt_create" & _
                          ") VALUES ('" & lng_k_athlete & "'" & _
                                ", '" & lng_fk_authorizations_01 & "'" & _
                                ", '" & 4 & "'" & _
                                ", '" & i_fk_status_entry_01 & "'" & _
                                ", '" & i_fk_status_view_01 & "'" & _
                                ", '" & i_authorizations_sort & "'" & _
                                ", '" & dt_now & "'" & _
                         ")"
                    'Response.Write(sql_tmp)	
                    objConn.Execute sql_tmp	
                end if 

                If Cint(i) > 0 and Cint(lng_fk_authorizations_01) > 0 Then
                        sql_tmp = "UPDATE tbl_0402_athlete_authorizations SET " & _
                        "lng_fk_authorizations = '" & lng_fk_authorizations_01 & "'" & _
                        ", i_type = '" & 4 & "'" & _
                        ", i_entry = '" & i_fk_status_entry_01 & "'" & _
                        ", i_view = '" & i_fk_status_view_01 & "'" & _
                        " WHERE lng_fk_athlete = '"  & lng_k_athlete& "' AND i_authorizations_sort = '" & i_authorizations_sort & "'"

                        'Response.Write(sql_tmp)
                        objConn.Execute sql_tmp	
                end if 

            'entfernen einer Zuordnung
            If Cint(i) > 0 and Cint(lng_fk_authorizations_01) = -1 Then
                    sql_tmp = "DELETE FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = '"  & lng_k_athlete& "' AND i_authorizations_sort = '" & i_authorizations_sort & "'"

                    'Response.Write(sql_tmp)		
                    objConn.Execute sql_tmp
                    i_delete = i_delete + 1
            end if

            '#2 -------------------------------------------------------------------------------------------------------------------------------
                i_authorizations_sort = 2
                lng_fk_authorizations_02 = Request("LST_Authorizations_02")
                If IsNull(Cint(lng_fk_authorizations_02)) or IsEmpty(Cint(lng_fk_authorizations_02)) or Cint(lng_fk_authorizations_02) = 0 Then
                    lng_fk_authorizations_02 = 0
                end if
                i_fk_status_entry_02 = Request("LST_Status_entry_02")
                i_fk_status_view_02 = Request("LST_Status_view_02")

                'zuerst muss ?berpr?ft werden ob es nicht schon einen datensatz gibt
                sql_tmp = "SELECT COUNT(1) AS i FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = " &  lng_k_athlete & " AND i_authorizations_sort = " & i_authorizations_sort
                Set rst_tmp = Server.CreateObject("ADODB.RecordSet")
                i = 0 
                rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly  
                    i = rst_tmp.Fields("i")
                    rst_tmp.close
                set rst_tmp = Nothing 

                'i_type = 4  >>> Trainer

                If Cint(i) = 0 and Cint(lng_fk_authorizations_02) > 0 Then
                    sql_tmp = "INSERT INTO tbl_0402_athlete_authorizations " & _
                         "(" & _
                              " lng_fk_athlete" & _
                              ", lng_fk_authorizations" & _
                              ", i_type" & _
                              ", i_entry" & _
                              ", i_view" & _
                              ", i_authorizations_sort" & _
                              ", dt_create" & _
                          ") VALUES ('" & lng_k_athlete & "'" & _
                                ", '" & lng_fk_authorizations_02 & "'" & _
                                ", '" & 4 & "'" & _
                                ", '" & i_fk_status_entry_02 & "'" & _
                                ", '" & i_fk_status_view_02 & "'" & _
                                ", '" & i_authorizations_sort & "'" & _
                                ", '" & dt_now & "'" & _
                         ")"

                    objConn.Execute sql_tmp	
                end if 

                If Cint(i) > 0 and Cint(lng_fk_authorizations_02) > 0 Then
                        sql_tmp = "UPDATE tbl_0402_athlete_authorizations SET " & _
                        "lng_fk_authorizations = '" & lng_fk_authorizations_02 & "'" & _
                        ", i_type = '" & 4 & "'" & _
                        ", i_entry = '" & i_fk_status_entry_02 & "'" & _
                        ", i_view = '" & i_fk_status_view_02 & "'" & _
                        " WHERE lng_fk_athlete = '"  & lng_k_athlete & "' AND i_authorizations_sort = " & i_authorizations_sort
                        'Response.Write(sql_tmp)
                        objConn.Execute sql_tmp	
                    objConn.Execute sql_tmp	
                end if 

                'entfernen einer Zuordnung
                If Cint(i) > 0 and Cint(lng_fk_authorizations_02) = -1 Then
                        sql_tmp = "DELETE FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = '"  & lng_k_athlete& "' AND i_authorizations_sort = '" & i_authorizations_sort & "'"

                        'Response.Write(sql_tmp)		
                        objConn.Execute sql_tmp
                        i_delete = i_delete + 1
                end if

            '#3 -------------------------------------------------------------------------------------------------------------------------------
                i_authorizations_sort = 3
                lng_fk_authorizations_03 = Request("LST_Authorizations_03")
                If IsNull(Cint(lng_fk_authorizations_03)) or IsEmpty(Cint(lng_fk_authorizations_03)) or Cint(lng_fk_authorizations_03) = 0 Then
                    lng_fk_authorizations_03 = 0
                end if
                i_fk_status_entry_03 = Request("LST_Status_entry_03")
                i_fk_status_view_03 = Request("LST_Status_view_03")

                'zuerst muss ?berpr?ft werden ob es nicht schon einen datensatz gibt
                sql_tmp = "SELECT COUNT(1) AS i FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = " &  lng_k_athlete & " AND i_authorizations_sort = " & i_authorizations_sort
                Set rst_tmp = Server.CreateObject("ADODB.RecordSet")
                i = 0 
                rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly  
                    i = rst_tmp.Fields("i")
                    rst_tmp.close
                set rst_tmp = Nothing 

                'i_type = 4  >>> Trainer

                If Cint(i) = 0 and Cint(lng_fk_authorizations_03) > 0 Then
                    sql_tmp = "INSERT INTO tbl_0402_athlete_authorizations " & _
                         "(" & _
                              " lng_fk_athlete" & _
                              ", lng_fk_authorizations" & _
                              ", i_type" & _
                              ", i_entry" & _
                              ", i_view" & _
                              ", i_authorizations_sort" & _
                              ", dt_create" & _
                          ") VALUES ('" & lng_k_athlete & "'" & _
                                ", '" & lng_fk_authorizations_03 & "'" & _
                                ", '" & 4 & "'" & _
                                ", '" & i_fk_status_entry_03 & "'" & _
                                ", '" & i_fk_status_view_03 & "'" & _
                                ", '" & i_authorizations_sort & "'" & _
                                ", '" & dt_now & "'" & _
                         ")"

                    objConn.Execute sql_tmp	
                end if 

                If Cint(i) > 0 and Cint(lng_fk_authorizations_03) > 0 Then
                        sql_tmp = "UPDATE tbl_0402_athlete_authorizations SET " & _
                        "lng_fk_authorizations = '" & lng_fk_authorizations_03 & "'" & _
                        ", i_type = '" & 4 & "'" & _
                        ", i_entry = '" & i_fk_status_entry_03 & "'" & _
                        ", i_view = '" & i_fk_status_view_03 & "'" & _
                        " WHERE lng_fk_athlete = '"  & lng_k_athlete & "' AND i_authorizations_sort = " & i_authorizations_sort
                        'Response.Write(sql_tmp)
                        objConn.Execute sql_tmp	
                    objConn.Execute sql_tmp	
                end if 

                'entfernen einer Zuordnung
                If Cint(i) > 0 and Cint(lng_fk_authorizations_03) = -1 Then
                        sql_tmp = "DELETE FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = '"  & lng_k_athlete& "' AND i_authorizations_sort = '" & i_authorizations_sort & "'"

                        'Response.Write(sql_tmp)		
                        objConn.Execute sql_tmp
                        i_delete = i_delete + 1
                end if

            '#4 ------------------------------------------------------------------------------------------------------------------------------
                i_authorizations_sort = 4
                lng_fk_authorizations_04 = Request("LST_Authorizations_04")
                If IsNull(Cint(lng_fk_authorizations_04)) or IsEmpty(Cint(lng_fk_authorizations_04)) or Cint(lng_fk_authorizations_04) = 0 Then
                    lng_fk_authorizations_04 = 0
                end if
                i_fk_status_entry_04 = Request("LST_Status_entry_04")
                i_fk_status_view_04 = Request("LST_Status_view_04")

                'zuerst muss ?berpr?ft werden ob es nicht schon einen datensatz gibt
                sql_tmp = "SELECT COUNT(1) AS i FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = " &  lng_k_athlete & " AND i_authorizations_sort = " & i_authorizations_sort
                Set rst_tmp = Server.CreateObject("ADODB.RecordSet")
                i = 0 
                rst_tmp.Open sql_tmp, objConn, adOpenStatic, adLockReadOnly  
                    i = rst_tmp.Fields("i")
                    rst_tmp.close
                set rst_tmp = Nothing 

                'i_type = 4  >>> Trainer

                If Cint(i) = 0 and Cint(lng_fk_authorizations_04) > 0 Then
                    sql_tmp = "INSERT INTO tbl_0402_athlete_authorizations " & _
                         "(" & _
                              " lng_fk_athlete" & _
                              ", lng_fk_authorizations" & _
                              ", i_type" & _
                              ", i_entry" & _
                              ", i_view" & _
                              ", i_authorizations_sort" & _
                              ", dt_create" & _
                          ") VALUES ('" & lng_k_athlete & "'" & _
                                ", '" & lng_fk_authorizations_04 & "'" & _
                                ", '" & 4 & "'" & _
                                ", '" & i_fk_status_entry_04 & "'" & _
                                ", '" & i_fk_status_view_04 & "'" & _
                                ", '" & i_authorizations_sort & "'" & _
                                ", '" & dt_now & "'" & _
                         ")"

                    objConn.Execute sql_tmp	
                end if 

                If Cint(i) > 0 and Cint(lng_fk_authorizations_04) > 0 Then
                        sql_tmp = "UPDATE tbl_0402_athlete_authorizations SET " & _
                        "lng_fk_authorizations = '" & lng_fk_authorizations_04 & "'" & _
                        ", i_type = '" & 4 & "'" & _
                        ", i_entry = '" & i_fk_status_entry_04 & "'" & _
                        ", i_view = '" & i_fk_status_view_04 & "'" & _
                        " WHERE lng_fk_athlete = '"  & lng_k_athlete & "' AND i_authorizations_sort = " & i_authorizations_sort
                        'Response.Write(sql_tmp)
                        objConn.Execute sql_tmp	
                    objConn.Execute sql_tmp	
                end if 

                'entfernen einer Zuordnung
                If Cint(i) > 0 and Cint(lng_fk_authorizations_04) = -1 Then
                        sql_tmp = "DELETE FROM tbl_0402_athlete_authorizations WHERE lng_fk_athlete = '"  & lng_k_athlete& "' AND i_authorizations_sort = '" & i_authorizations_sort & "'"

                        'Response.Write(sql_tmp)		
                        objConn.Execute sql_tmp
                        i_delete = i_delete + 1
                end if

        End Select
End Function

sub getTimeZonesCode()
    On Error Resume Next
    dim sql
    sql = "select * from tbl_0971_time_zones order by id"
    dim rs
    Set rs = Server.CreateObject("ADODB.RecordSet")
    rs.Open sql, objConn, adOpenStatic, adLockReadOnly
    dim html, selected, offset
    if g_time_zone = "" then
        g_time_zone = "0.0"
    end if
    Do While Not rs.EOF
        offset = rs.Fields("offset")
        if offset = g_time_zone then
            selected = "selected"
        else
            selected = ""
        end if
		html = html & "<option " & selected & " value='"&rs.Fields("offset")&"'>(UTC "&rs.Fields("offset")&") "&rs.Fields("name")&"</option>\n"
	    rs.MoveNext
	Loop
	rs.Close
    Set rs = Nothing
   Response.Write(html)
   If Err.Number Then
		Response.Write("//Errors: " & Err.Description)
		Err.Clear
   End If
end sub

sub getEmailsCode(lng_k_athlete, is_first_email)
    On Error Resume Next
    dim sql
    sql = "select str_athlete_email, str_athlete_email_02 from tbl_0401_athlete where `lng_k_athlete` = '"&lng_k_athlete&"'"
    dim rs
    Set rs = Server.CreateObject("ADODB.RecordSet")
    rs.Open sql, objConn, adOpenStatic, adLockReadOnly
    dim html, first_email, second_email, selected, g
    If Not rs.EOF Then
        first_email = rs.Fields("str_athlete_email")
        second_email = rs.Fields("str_athlete_email_02")
        if is_first_email then
            g = g_first_email
        else 
            g = g_second_email
        end if
    	if first_email <> "" then
            if first_email = g then
                selected = "selected"
            else
                selected = ""
            end if
            html = html & "<option "&selected&" value='"&first_email&"'>"&first_email&"</option>\n"
        end if
        if second_email <> "" then
            if second_email = g then
                selected = "selected"
            else
                selected = ""
            end if
            html = html & "<option "&selected&" value='"&second_email&"'>"&second_email&"</option>\n"
        end if
        html = html & "<option value='-1'>"&fc_value_string(Session("ses_i_language"), "var_remind_13")&"</option>\n"
    End if
	rs.Close
	Set rs = Nothing
    Response.Write(html)
    If Err.Number Then
		Response.Write("//Errors: " & Err.Description)
		Err.Clear
   End If
end sub

sub getIntervalOrRemindMeCode(interval)
    On Error Resume Next
    dim intervalVariations(2)
    intervalVariations(0) = 30
    intervalVariations(1) = 45
    intervalVariations(2) = 60

    dim remindMeVariations(7)
    remindMeVariations(0) = 1
    remindMeVariations(1) = 2
    remindMeVariations(2) = 3
    remindMeVariations(3) = 4
    remindMeVariations(4) = 5
    remindMeVariations(5) = 6
    remindMeVariations(6) = 7
    remindMeVariations(7) = 0

    dim html, arr, text, text1, selected, g
    
    if interval then
        arr = intervalVariations
        text = fc_value_string(Session("ses_i_language"), "var_remind_11")
        g = g_interval
    else
        arr = remindMeVariations
        text = fc_value_string(Session("ses_i_language"), "var_remind_12")
        g = g_days_ahead
    end if

    dim el
    if g = "" then g = 1 end if
    for each el in arr
        if el = 0 then
            text1 = fc_value_string(Session("ses_i_language"), "var_remind_15")
        else
            text1 = Replace(text, "%d", el)
        end if
        if g = el then
            selected = "selected"
        else
            selected = ""
        end if
        html = html & "<option "&selected&" value='"&el&"'>"&text1&"</option>\n"
    next
    Response.Write(html)
    If Err.Number Then
		Response.Write("//Errors: " & Err.Description)
		Err.Clear
   End If
end sub

'http://www.growmetry.com/apx_translate/index_admin.asp?a1=Walker&a2=bermygolfer
%>